home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / dev / misc / BoulderEngine.lha / source / BOULDER0.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-30  |  13.5 KB  |  462 lines

  1. /*
  2. ============================(BOULDER0.C)==Ver.2.0========
  3. == TO COMPILE : CC FILE.C +L -S                        ==
  4. == TO LINK    : LN FILE.O +LC32  (It's not main body)  ==
  5. ==                                                     ==
  6. == ©1993 by Savel soft inc.                            ==
  7. ==                Ver2.0 ©1995.03.01-xx                ==
  8. ==                                                     ==
  9. == Rockford® & Boulder Dash® is © by First Star soft.  ==
  10. ========Cia BOULDER-DASH Grafinis modulis================
  11. */
  12. #include "INCLUDE:stdio.h"
  13. #include "INCLUDE:exec/types.h"
  14. #include "INCLUDE:devices/audio.h"
  15. #include "INCLUDE:graphics/gfx.h"
  16. #include "INCLUDE:graphics/copper.h"
  17. #include "INCLUDE:graphics/view.h"
  18. #include "INCLUDE:graphics/rastport.h"
  19. #include "INCLUDE:graphics/gels.h"
  20. #include "INCLUDE:graphics/regions.h"
  21. #include "INCLUDE:graphics/clip.h"
  22. #include "INCLUDE:graphics/sprite.h"
  23. #include "INCLUDE:exec/exec.h"
  24. #include "INCLUDE:graphics/text.h"
  25. #include "INCLUDE:graphics/gfxbase.h"
  26. #include "INCLUDE:graphics/gfxmacros.h"
  27. #include "INCLUDE:hardware/dmabits.h"
  28. #include "INCLUDE:hardware/custom.h"
  29. #include "INCLUDE:exec/memory.h"
  30. #include "INCLUDE:intuition/intuition.h"
  31. #define e(x,y) ek[y*30+x]
  32. #define k(x,y) kk[y*30+x]
  33.  
  34. #define DEPTH 3L
  35. #define WIDTH 800L
  36. #define HEIGHT 512L
  37. #define VPWIDTH 640L
  38. #define VPHEIGHT 256L
  39.  
  40. #define NOT_ENOUGH_MEMORY -1000
  41. STATIC UBYTE ek[830];
  42. STATIC UBYTE kk[830];
  43. STATIC UBYTE Adzin,Abum;
  44. STATIC SHORT vxoff,vyoff;
  45. SHORT galima();
  46. LONG hsefektai();
  47. STATIC SHORT nereikia,TIM,CRISTAL,HMAGMA;
  48. /* ------ cia prasideda displejus ----- */
  49. struct View view;
  50. struct ViewPort viewport;
  51. struct ColorMap *cm;
  52. struct RasInfo rasinfo;
  53. struct BitMap bitmap;
  54. struct RastPort rastport;
  55. extern struct ColorMap *GetColorMap();
  56. struct GfxBase *GfxBase;
  57. struct View *oldview;
  58. USHORT colortable[]={
  59. 0x000,0xfff,0x44e,0x0c1,
  60. 0x999,0x445,0x999,0xd10,
  61. 0x356,0x55f,0x888,0xc57,
  62. 0x115,0x023,0xf00,0x209,
  63. 0x127,0x213,0x209,0x15f,
  64. 0x190,0x088,0x090,0xf22,
  65. 0x333,0x444,0x555,0x666,
  66. 0x777,0x888,0x999,0xaaa,
  67. 0 };
  68. UWORD *colorpalette;
  69.  
  70. pasiruosk()
  71. {
  72. LONG i,n;
  73. UBYTE *displaymem;
  74.  GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L);
  75.  if (GfxBase==NULL) exit(100);
  76.  
  77.  oldview=GfxBase->ActiView;
  78.  
  79.  InitView(&view);
  80.  InitVPort(&viewport);
  81.  view.ViewPort = &viewport;
  82.  view.Modes =HIRES;
  83.  InitBitMap(&bitmap,DEPTH,WIDTH,HEIGHT);
  84.  InitRastPort(&rastport);
  85.  rastport.BitMap = &bitmap;
  86.  rasinfo.BitMap = &bitmap;
  87.  vxoff=63; vyoff=0;
  88.  rasinfo.RxOffset = vxoff;      /* Kad nesimatytu pvz. */
  89.  rasinfo.RyOffset = vyoff;
  90.  rasinfo.Next = NULL;
  91.  
  92.  viewport.DWidth = VPWIDTH;
  93.  viewport.DHeight = VPHEIGHT;
  94.  viewport.RasInfo = &rasinfo;
  95.  viewport.DyOffset = 0;
  96.  viewport.DxOffset = 0;
  97.  viewport.Modes =HIRES; /* DUALPF , PFBA , HIRES , LACE , HAM ,SPRITES*/
  98.  cm = GetColorMap(32L);
  99.  if (cm == NULL) { exit(100); }
  100.  colorpalette = (UWORD *)cm->ColorTable;
  101.  for(i=0;i<32;i++) { *colorpalette++ = colortable[i]; }
  102.  viewport.ColorMap = cm;
  103.  for(i=0; i<DEPTH;i++) {
  104.   bitmap.Planes[i] = (PLANEPTR) AllocRaster(WIDTH,HEIGHT);
  105.   }
  106.   MakeVPort(&view,&viewport);
  107.   MrgCop(&view);
  108.   LoadView(&view);
  109.   }
  110. PrntI(x,y,n)
  111. SHORT x,y,n;
  112. {
  113. ClipBlit(&rastport,(long)42,(long)n*10L,&rastport,x,y,(long)10,(long)10,(long)0xC0);
  114. }
  115. Prnt(x,y,n)
  116. USHORT x,y,n;
  117. {
  118. USHORT a;
  119. if(n>999){ return; }
  120. a=n/100; PrntI(x,y,a); n-=a*100; a=n/10; PrntI(x+10,y,a);
  121. n-=a*10; PrntI(x+20,y,n);
  122. }
  123. PrntL(x,y,n)
  124. USHORT x,y;
  125. ULONG n;
  126. {
  127. ULONG a;
  128. a=n/1000; Prnt(x,y,a); n-=a*1000; Prnt(x+30,y,n);
  129. }
  130. hide()
  131. {
  132. LONG x,y,n,i=0;
  133. Audiodzin();
  134. for(n=0;n<7;n++)
  135. { for(x=0;x<30;x++)
  136. { for(y=0;y<26;y++)
  137. { if(galima(47) && e(x,y)!=7) { e(x,y)=7;
  138. ClipBlit(&rastport,(long)0,(long)140,&rastport,(long)x*20L+63L,(long)y*19,(long)20,(long)19,(long)0xC0); }
  139. i=hsefektai(i);
  140. } } }
  141. for(x=0;x<30;x++) { for(y=0;y<26;y++) {
  142. if(e(x,y)!=7) { set(x,y,7);
  143. i=hsefektai(i);
  144.  } } } Audiopip(0);
  145. }
  146. LONG hsefektai(i)
  147. LONG i;
  148. {
  149.  Audiodzin2(i);
  150.  i++;
  151.  if(i==30) {i=0;}
  152.  return(i);
  153. }
  154. show()
  155. {
  156. LONG x,y,n,xx,yy,zz,ty,i=0;
  157.    for(y=0; y<26; y++)
  158.     {
  159.      for(x=0; x<30; x++)
  160.       { ClipBlit(&rastport,(long)0,(long)140,&rastport,(long)x*20L+63L,(long)y*19,(long)20,(long)19,(long)0xC0); }
  161.      }
  162. for(xx=0;xx<780;xx++) {kk[xx]=11; }
  163. Audiodzin();
  164. for(xx=0;xx<6;xx++)
  165. {
  166.  for(x=0;x<30;x++)
  167.  {
  168.   for(y=0;y<26;y++)
  169.   {
  170.    if(k(x,y)>10)
  171.     {
  172.      if(galima((short)37)) {
  173.           i=hsefektai(i);
  174.          set(x,y,e(x,y)); if(e(x,y)==9)
  175.        { set(x,y,7); e(x,y)=9;}
  176.        if(e(x,y)==10){ty=y;}
  177.        }
  178.     }
  179.   }
  180.  }
  181. }
  182. for(x=0;x<30;x++)
  183. {
  184.  for(y=0;y<26;y++)
  185.  {
  186.   if(k(x,y)>10) { 
  187.      i=hsefektai(i);
  188.      set(x,y,e(x,y)); if(e(x,y)==9)
  189.     { set(x,y,7); e(x,y)=9;}
  190.     if(e(x,y)==10){ty=y;}
  191.    }
  192.  }
  193. } Audiopip(0);
  194. if(ty>16) {scrolll(256); return;}
  195. if(ty>8) {scrolll(128); return;}
  196. if(ty<9) {scrolll(0); }
  197. } /* END of SHOW */
  198.  
  199. set(x,y,n)
  200. LONG x,y,n;
  201. {
  202. LONG xx;
  203.  k(x,y)=0;
  204.  e(x,y)=n;
  205.  if(n>14) {
  206.            if(n==15){n=8;}
  207.            if(n==16){n=6;}
  208.            if(n==17){n=11;}
  209.            if(n==20){n=10;}
  210.           }
  211.  xx=63L+x*20L;
  212. if(n<12)
  213.  ClipBlit(&rastport,(long)0,(long)n*20,&rastport,(long)xx,(long)y*19,(long)20,(long)19,(long)0xc0);
  214. else
  215.  {
  216. ClipBlit(&rastport,(long)21,(long)20L*(n-12),&rastport,(long)xx,(long)y*19,(long)20,(long)19,(long)0xc0);}
  217.   }
  218. /* END of SET */
  219. Makegraphics()
  220. {
  221. LONG n,a,b;
  222.  
  223. SetAPen(&rastport,4L); RectFill(&rastport,0L,100L,20L,103L);
  224. RectFill(&rastport,0L,115L,20L,119L);
  225. SetAPen(&rastport,3L); RectFill(&rastport,0L,104L,20L,107L);
  226. RectFill(&rastport,0L,112L,20L,114L);
  227. SetAPen(&rastport,2L); RectFill(&rastport,0L,108L,20L,111L);
  228. SetAPen(&rastport,0L);
  229. for(n=0;n<20;n++) {Move(&rastport,n,99L); Draw(&rastport,20L-n,120L); }
  230.                              /* Supaprastintas drugelis */
  231.  
  232. SetAPen(&rastport,1L); RectFill(&rastport,21L,20L,41L,39L);
  233. SetAPen(&rastport,0L); plot(21,26); Draw(&rastport,42L,26L);
  234. plot(21,32); Draw(&rastport,42L,32L);
  235. plot(21,39); Draw(&rastport,42L,39L);
  236. /* judancios sienos variantas */
  237.  
  238.  
  239. SetAPen(&rastport,5L);
  240. for(n=8;n>0;n--) { DrawEllipse(&rastport,30L,49L,n,n); }
  241. SetAPen(&rastport,6L);
  242. DrawEllipse(&rastport,30L,49L,9L,8L);
  243. plot(30,43); plot(30,44); plot(33,46); plot(36,48);
  244. SetAPen(&rastport,7L); plot(29,57); plot(30,56);
  245. plot(32,56); plot(34,55);
  246. /* BOMBA */
  247.  
  248. SetAPen(&rastport,1L); RectFill(&rastport,22L,121L,41L,130L);
  249. SetAPen(&rastport,6L); plot(26,132); plot(27,133);
  250. plot(28,134); plot(29,135); /* Akmenu generat. */
  251.  
  252. SetAPen(&rastport,2L); RectFill(&rastport,28L,145L,35L,157L);
  253. SetAPen(&rastport,1L); RectFill(&rastport,22L,141L,41L,150L);
  254. SetAPen(&rastport,0L); plot(22,145); Draw(&rastport,141L,145L);
  255. /* Bril. generatorius */
  256.  
  257. SetAPen(&rastport,7L); RectFill(&rastport,22L,193L,41L,199L);
  258. SetAPen(&rastport,1L); RectFill(&rastport,23L,194L,40L,198L);
  259. SetAPen(&rastport,3L); RectFill(&rastport,28L,189L,35L,192L);
  260. /* Mina */
  261.  
  262. SetAPen(&rastport,1L); RectFill(&rastport,31L,226L,32L,236L);
  263. RectFill(&rastport,25L,230L,35L,231L); SetAPen(&rastport,2L);
  264. plot(31,230); plot(32,231); SetAPen(&rastport,4L);
  265. plot(32,230); plot(31,231); /* Juod. skyle. */
  266.  
  267. SetAPen(&rastport,6L);
  268. for(n=8;n>0;n--) { DrawEllipse(&rastport,10L,49L,n,n); }
  269. SetAPen(&rastport,1L);
  270. DrawEllipse(&rastport,10L,49L,9L,8L);
  271. plot(10,43); plot(10,44); plot(13,46); plot(16,48);
  272. SetAPen(&rastport,5L); plot(9,57); plot(10,56);
  273. plot(12,56); plot(14,55);  /* Akmuo */
  274.  
  275. for(n=0;n<9;n++)
  276.  {SetAPen(&rastport,n/2+2);
  277.   Move(&rastport,9-n,60+n);
  278.   Draw(&rastport,n+9,60+n);
  279.  }
  280. for(n=9;n>0;n--)
  281.  {SetAPen(&rastport,n/2+2);
  282.   Move(&rastport,9-n,79-n);
  283.   Draw(&rastport,n+9,79-n);   /* Kristalas */
  284.  }
  285.  
  286. SetAPen(&rastport,2L); RectFill(&rastport,1L,81L,20L,99L);
  287. SetAPen(&rastport,3L); RectFill(&rastport,4L,84L,15L,95L);
  288. SetAPen(&rastport,4L); RectFill(&rastport,7L,87L,12L,92L); /* Blake */
  289.  
  290.  
  291. SetAPen(&rastport,6L);
  292. RectFill(&rastport,0L,20L,20L,39L);
  293. SetAPen(&rastport,0L); Move(&rastport,7L,29L); Draw(&rastport,18L,27L);
  294. Move(&rastport,8L,23L); Draw(&rastport,20L,21L);
  295. plot(5,21); plot(13,22); SetAPen(&rastport,1L); plot(16,25);
  296. plot(19,27);                          /* Zeme */
  297.  
  298. SetAPen(&rastport,1L);
  299. RectFill(&rastport,0L,159L,20L,179L);
  300. SetAPen(&rastport,0L);
  301. Move(&rastport,0L,164L);
  302. Draw(&rastport,20L,164L);
  303. Move(&rastport,0L,169L);
  304. Draw(&rastport,20L,169L);
  305. Move(&rastport,0L,174L); Draw(&rastport,20L,174L);
  306. Move(&rastport,0L,178L); Draw(&rastport,20L,178L);
  307. Move(&rastport,3L,159L); Draw(&rastport,3L,164L);
  308. Move(&rastport,13L,159L); Draw(&rastport,13L,164L);
  309. Move(&rastport,8L,164L); Draw(&rastport,8L,169L);
  310. Move(&rastport,18L,164L); Draw(&rastport,18L,169L);
  311. Move(&rastport,3L,169L); Draw(&rastport,3L,174L);
  312. Move(&rastport,13L,169L); Draw(&rastport,13L,174L);
  313. Move(&rastport,8L,174L); Draw(&rastport,8L,178L);
  314. Move(&rastport,18L,174L); Draw(&rastport,18L,178L);   /* Muras */
  315.  
  316. SetAPen(&rastport,6L);
  317. RectFill(&rastport,1L,141L,20L,159L);
  318. spot(4,142); spot(4,152); spot(13,142); spot(13,152); /* metAlas */
  319.  
  320. SetAPen(&rastport,7L);
  321. RectFill(&rastport,0L,120L,20L,139L);
  322. SetAPen(&rastport,0L);
  323. RectFill(&rastport,3L,123L,7L,127L);
  324. RectFill(&rastport,13L,132L,16L,134L);
  325. /* Kvazi Magme */
  326. SetAPen(&rastport,1L); square(0,180,20,199);
  327. square(3,183,17,196);
  328. SetAPen(&rastport,7L); square(1,181,19,198);
  329. SetAPen(&rastport,3L); square(2,182,18,197);
  330.  
  331. SetAPen(&rastport,6L);
  332. RectFill(&rastport,3L,203L,14L,207L);
  333. Move(&rastport,6L,208L); Draw(&rastport,11L,208L);
  334. Move(&rastport,4L,202L); Draw(&rastport,5L,202L);
  335. Move(&rastport,12L,202L); Draw(&rastport,13L,202L);
  336. RectFill(&rastport,2L,205L,15L,206L);
  337. SetAPen(&rastport,1L); Move(&rastport,0L,213L); Draw(&rastport,1L,213L);
  338. Draw(&rastport,4L,210L); Draw(&rastport,14L,210L); Draw(&rastport,17L,213L);
  339. Draw(&rastport,18L,213L); RectFill(&rastport,5L,212L,13L,214L);
  340. RectFill(&rastport,4L,215L,5L,217L); RectFill(&rastport,13L,215L,14L,217L);
  341. Move(&rastport,2L,217L); Draw(&rastport,3L,217L); Move(&rastport,15L,217L);
  342. Draw(&rastport,16L,217L); plot(6,211); plot(21,211);
  343. SetAPen(&rastport,7L); Move(&rastport,6L,213L); Draw(&rastport,11L,213L);
  344. SetAPen(&rastport,0L); RectFill(&rastport,4L,205L,6L,206L);
  345. RectFill(&rastport,11L,205L,13L,206L); /* Rockford ® */
  346.  
  347. SetAPen(&rastport,1L); Move(&rastport,5L,225L); Draw(&rastport,15L,235L);
  348. Move(&rastport,7L,233L); Draw(&rastport,13L,225L);
  349. SetAPen(&rastport,7L); Move(&rastport,7L,226L); Draw(&rastport,13L,227L);
  350. Move(&rastport,5L,230L); Draw(&rastport,15L,229L);
  351. SetAPen(&rastport,1L); Move(&rastport,0L,221L); Draw(&rastport,20L,238L);
  352. Move(&rastport,20L,221L); Draw(&rastport,0,239L); plot(9,229); plot(10,230);
  353. plot(5,230); plot(15,235); Move(&rastport,9L,223L);
  354. Draw(&rastport,11L,239L); Draw(&rastport,8L,225L);
  355. Move(&rastport,0L,231L); Draw(&rastport,20L,229L);
  356. Draw(&rastport,4L,229L);
  357.  /* Blast ! */
  358. a=43; b=48;
  359. SetAPen(&rastport,5L); RectFill(&rastport,42L,0L,62L,250L);
  360. SetAPen(&rastport,1L); Move(&rastport,a,1L); Draw(&rastport,b,1L);
  361. Draw(&rastport,b,8L); Draw(&rastport,a,8L); Draw(&rastport,a,1L);
  362.  
  363. Move(&rastport,45L,11L); Draw(&rastport,45L,18L); plot(44,12);
  364.  
  365. Move(&rastport,a,21L); Draw(&rastport,b,21L);
  366. Draw(&rastport,b,24L); Draw(&rastport,a,24L);
  367. Draw(&rastport,a,28L); Draw(&rastport,b,28L);
  368.  
  369. Move(&rastport,a,31L); Draw(&rastport,b,31L);
  370. Draw(&rastport,b,38L); Draw(&rastport,a,38L);
  371. Move(&rastport,a,34L); Draw(&rastport,b,34L);
  372.  
  373. Move(&rastport,a,41L); Draw(&rastport,a,44L);
  374. Draw(&rastport,b,44L); Move(&rastport,b,41L);
  375. Draw(&rastport,b,48L);
  376.  
  377. Move(&rastport,b,51L); Draw(&rastport,a,51L);
  378. Draw(&rastport,a,54L); Draw(&rastport,b,54L);
  379. Draw(&rastport,b,58L); Draw(&rastport,a,58L);
  380.  
  381. Move(&rastport,b,61L); Draw(&rastport,a,61L);
  382. Draw(&rastport,a,68L); Draw(&rastport,b,68L);
  383. Draw(&rastport,b,64L); Draw(&rastport,a,64L);
  384.  
  385. Move(&rastport,a,71L); Draw(&rastport,b,71L);
  386. Draw(&rastport,b,78L);
  387.  
  388. Move(&rastport,a,81L); Draw(&rastport,b,81L);
  389. Draw(&rastport,b,88L); Draw(&rastport,a,88L);
  390. Draw(&rastport,a,81L); Move(&rastport,a,84L);
  391. Draw(&rastport,b,84L);
  392.  
  393. Move(&rastport,b,94L); Draw(&rastport,a,94L);
  394. Draw(&rastport,a,91L); Draw(&rastport,b,91L);
  395. Draw(&rastport,b,98L); Draw(&rastport,a,98L);
  396.  /* Tai buvo skaiciai nuo 0 iki 9 */
  397. Move(&rastport,a,101L); Draw(&rastport,a,108L); Draw(&rastport,b,108L);
  398. Move(&rastport,45L,111L); Draw(&rastport,45L,118L);
  399. Move(&rastport,a,121L); Draw(&rastport,45L,128L);
  400. Draw(&rastport,48L,121L);
  401. Move(&rastport,b,131L); Draw(&rastport,a,131L); Draw(&rastport,a,138L);
  402. Draw(&rastport,b,138L); Move(&rastport,a,134L); Draw(&rastport,b,134L);
  403. Move(&rastport,b,141L); Draw(&rastport,a,141L); Draw(&rastport,a,148L);
  404. Draw(&rastport,b,148L);
  405. Move(&rastport,a,158L); Draw(&rastport,a,151L); Draw(&rastport,b,151L);
  406. Draw(&rastport,b,154L); Draw(&rastport,a,154L); Draw(&rastport,b,158L);
  407. Move(&rastport,a,161L); Draw(&rastport,b,161L); Move(&rastport,45L,161L);
  408. Draw(&rastport,45L,168L);
  409. Move(&rastport,a,171L); Draw(&rastport,a,178L); Move(&rastport,b,171L);
  410. Draw(&rastport,b,178L); Move(&rastport,a,174L); Draw(&rastport,b,174L);
  411. Move(&rastport,a,184L); Draw(&rastport,b,184L);
  412.  
  413. } /* END of Makegraphics */
  414. square(x,y,x2,y2)
  415. LONG x,y,x2,y2;
  416. { Move(&rastport,x,y); Draw(&rastport,x2,y); Draw(&rastport,x2,y2);
  417. Draw(&rastport,x,y2); Draw(&rastport,x,y); }
  418. spot(x,y)
  419. LONG x,y;
  420. { SetAPen(&rastport,0L); RectFill(&rastport,x,y,x+4L,y+4L);
  421.   SetAPen(&rastport,5L); RectFill(&rastport,x-1L,y-1L,x+3,y+3);
  422. }
  423. plot(x,y)
  424. LONG x,y;
  425. { Move(&rastport,x,y); Draw(&rastport,x,y); }
  426. Tekstscreen(xx,yy)
  427. SHORT xx,yy;
  428. {
  429.   rasinfo.RxOffset = xx;
  430.   rasinfo.RyOffset = yy;
  431.   MakeVPort(&view,&viewport);
  432.   MrgCop(&view);
  433.   LoadView(&view);
  434. }
  435.  
  436. /* --------------------------------------------------------------*/
  437. FMemory()
  438. {
  439. LONG i;
  440. LoadView(oldview);
  441. WaitTOF(); Delay(1);
  442. for(i=0;i<DEPTH; i++) { if (bitmap.Planes[i] != NULL) {
  443.   FreeRaster(bitmap.Planes[i],WIDTH,HEIGHT);
  444.  }}
  445. if (cm != NULL) FreeColorMap(cm);
  446. FreeVPortCopLists(&viewport);
  447. FreeCprList(view.LOFCprList);
  448. CloseLibrary(GfxBase);
  449. return;
  450. }
  451.  
  452. SHORT galima(range)
  453. short range;
  454. {
  455. static int konst;
  456. short l=0;
  457. konst+=range;
  458. if(konst>254) {konst-=254; l=1; }
  459. return(l);
  460. }
  461.  
  462.